package com.anyou.mall.dri.controller;

import com.anyou.common.annotation.Log;
import com.anyou.common.core.controller.BaseController;
import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.core.page.TableDataInfo;
import com.anyou.common.enums.BusinessType;
import com.anyou.common.utils.poi.ExcelUtil;
import com.anyou.mall.dri.domain.TeamAudit;
import com.anyou.mall.dri.param.IsPassTeamAuditParam;
import com.anyou.mall.dri.service.ITeamAuditService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 司机加盟团队申请信息表Controller
 *
 * @author gaochaohao
 * @date 2022-03-22
 */
@Api(tags = "司机加盟团队申请信息表")
@RestController
@RequestMapping("/dri/teamAudit")
public class TeamAuditController extends BaseController
{
    @Autowired
    private ITeamAuditService teamAuditService;

    /**
     * 查询司机加盟团队申请信息表列表
     */
    @ApiOperation("查询司机加盟团队申请信息表列表")
    @PreAuthorize("@ss.hasPermi('dri:teamAudit:list')")
    @GetMapping("/list")
    public TableDataInfo<List<TeamAudit>> list(TeamAudit teamAudit)
    {
        startPage();
        List<TeamAudit> list = teamAuditService.selectTeamAuditList(teamAudit);
        return getDataTable(list);
    }

    /**
     * 导出司机加盟团队申请信息表列表
     */
    @ApiOperation("导出司机加盟团队申请信息表列表")
    @PreAuthorize("@ss.hasPermi('dri:teamAudit:export')")
    @Log(title = "司机加盟团队申请信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TeamAudit teamAudit)
    {
        List<TeamAudit> list = teamAuditService.selectTeamAuditList(teamAudit);
        ExcelUtil<TeamAudit> util = new ExcelUtil<TeamAudit>(TeamAudit.class);
        util.exportExcel(response, list, "司机加盟团队申请信息表数据");
    }

    /**
     * 获取司机加盟团队申请信息表详细信息
     */
    @ApiOperation("获取司机加盟团队申请信息表详细信息")
    @PreAuthorize("@ss.hasPermi('dri:teamAudit:query')")
    @GetMapping(value = "/{teamAuditId}")
    public ApiResult<TeamAudit> getInfo(@PathVariable("teamAuditId") Long teamAuditId)
    {
        return ApiResult.success(teamAuditService.selectTeamAuditByTeamAuditId(teamAuditId));
    }

    /**
     * 新增司机加盟团队申请信息表
     */
    @ApiOperation("新增司机加盟团队申请信息表")
    @PreAuthorize("@ss.hasPermi('dri:teamAudit:add')")
    @Log(title = "司机加盟团队申请信息表", businessType = BusinessType.INSERT)
    @PostMapping
    public ApiResult add(@RequestBody TeamAudit teamAudit)
    {
        return ApiResult.success(teamAuditService.insertTeamAudit(teamAudit));
    }

    /**
     * 修改司机加盟团队申请信息表
     */
    @ApiOperation("修改司机加盟团队申请信息表")
    @PreAuthorize("@ss.hasPermi('dri:teamAudit:edit')")
    @Log(title = "司机加盟团队申请信息表", businessType = BusinessType.UPDATE)
    @PutMapping
    public ApiResult edit(@RequestBody TeamAudit teamAudit)
    {
        return ApiResult.success(teamAuditService.updateTeamAudit(teamAudit));
    }

    /**
     * 删除司机加盟团队申请信息表
     */
    @ApiOperation("删除司机加盟团队申请信息表")
    @PreAuthorize("@ss.hasPermi('dri:teamAudit:remove')")
    @Log(title = "司机加盟团队申请信息表", businessType = BusinessType.DELETE)
    @DeleteMapping("/{teamAuditIds}")
    public ApiResult remove(@PathVariable Long[] teamAuditIds)
    {
        return ApiResult.success(teamAuditService.deleteTeamAuditByTeamAuditIds(teamAuditIds));
    }

    /**
     * 是否通过审核
     */
    @ApiOperation("是否通过审核")
    @PreAuthorize("@ss.hasPermi('dri:teamAudit:isPass')")
    @Log(title = "司机加盟团队申请信息表",businessType = BusinessType.UPDATE)
    @PostMapping("/isPass")
    public ApiResult isPassTeamAudit(@RequestBody IsPassTeamAuditParam isPassTeamAuditParam) {
        return teamAuditService.isPassTeamAudit(isPassTeamAuditParam);
    }

    /**
     * 批量通过审核
     */
    @ApiOperation("批量通过审核")
    @PreAuthorize("@ss.hasPermi('dri:teamAudit:allPass')")
    @Log(title = "司机加盟团队申请信息表", businessType = BusinessType.UPDATE)
    @PostMapping("/allPass/{teamAuditIds}")
    public ApiResult allPassTeamAudit(@PathVariable Long[] teamAuditIds) {
        return teamAuditService.allPassTeamAudit(teamAuditIds);
    }

    /**
     * 获取所有团队信息
     */
    @ApiOperation("获取所有团队信息")
    @PreAuthorize("@ss.hasPermi('dri:teamAudit:allList')")
    @GetMapping("/allList")
    public ApiResult<List<TeamAudit>> getAllList() {
        List<TeamAudit> list = teamAuditService.selectPassTeamAuditList();
        return ApiResult.success(list);
    }

}
